<script type="text/javascript">
	
function hexToRgb(str) {
	str = str.slice(1);

	let arr = [];
	for(let i = 0; i < str.length; i+=2) {
		arr.push(parseInt(str.substr(i, 2)-0, 16));
	}

	return arr;
}

function rgbToHex(arr) {
	let str = ['#'];
	arr.forEach(function(element, index) {
		str.push(element.toString(16));
	})

	return str.join('');
}
const res1 = hexToRgb('#456789');
const res2 = rgbToHex([69, 103, 137]);
console.log(res1);
console.log(res2);

</script>